/**
 * Created by Ace.C on 2016/4/15.
 */
class BasePanel extends BaseSprite {

    protected btn_close: ButtonEx;

    constructor() {
        super();

        this.layer = gameManager.layerManager.panelLayer;
    }

    childrenCreated() {
        super.childrenCreated();

        this.horizontalCenter = 0;
        this.verticalCenter = 0;

        if (this.btn_close) {
            this.btn_close.addEventListener(egret.TouchEvent.TOUCH_TAP, this.hide, this);
        }
    }

    show(eff: number = 1, dark: boolean = true): void {
        super.show();

        GameSound.play('sound_panel_show');

        if (!this.layer.contains(this)) {
            PopUpUtils.addPopUp(this, dark, eff);
        }

    }

    hide(): void {
        super.hide();

        GameSound.play('sound_panel_close');

        if (this.layer.contains(this)) {
            PopUpUtils.removePopUp(this, 1);
        }
    }
}